<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<jsp:include page="include_header.jsp" flush="false" />


<c:set var="page" value="${param.p}" />
<c:set var="pageCount" value="${topic.replies / 50}" />


<div class="status-panel clearfix">
	<div>
		[<a href="${pageContext.request.contextPath}/topics">首頁</a>]
	</div>
	<div>
		[<a href="${pageContext.request.contextPath}/composeMessage?messageId=${topic.messageId}">回覆</a>]
	</div>
	<div>
		<c:if test="${page > 1}">
			[<a href="/topic?id=${topic.messageId}&p=${page-1}">&lt;上一頁</a>]
		</c:if>
		<c:if test="${pageCount > 1}">
			<select onchange="jumpToPage(this.value);">
				<option>跳至...</option>
				<c:forEach var="index" begin="1" end="${pageCount + 1}">
					<option value="/topic?id=${topic.messageId}&p=${index}">${index}</option>
				</c:forEach>
			</select>
		</c:if>
		<c:if test="${page < pageCount}">
			[<a href="/topic?id=${topic.messageId}&p=${page+1}">下一頁&gt;</a>]
		</c:if>
	</div>
</div>


<div id="message-title">
	${topic.messageTitle}
	<br /><br />
	[時間: ${usedTime}]
	[回覆: ${topic.replies}]
	[評分${topic.rating}]
</div>

<div id="message-title-panel">
	<div class="head head-big">
		<ul id="sections">
			<li class="section-description current">
				<c:if test="${topic.authorGender eq 'M'}">
					<span class="author-m">${topic.authorName}</span>
				</c:if>
				<c:if test="${topic.authorGender eq 'F'}">
					<span class="author-f">${topic.authorName}</span>
				</c:if>
			</li>
			<li class="section-stats ">
				[<a href="ComposeMessage.jsp?composeType=Reply&messageId=${topic.messageId}&replyId=1">引用文章</a>]
			</li>
		</ul>
	</div>
	<div>
		${topic.messageBody}
	</div>
</div>


<!--Show message content-->
<div id="message-content-panel">
<ol>
	<c:forEach var="message" items="${topic.messages}">
		<li>
			<div id="message-title-panel">
				<div class="head head-big">
					<ul id="sections">
						<li class="section-description current">
							<c:if test="${message.authorGender eq 'M'}">
								<span class="author-m">${message.authorName}</span>
							</c:if>
							<c:if test="${message.authorGender eq 'F'}">
								<span class="author-f">${message.authorName}</span>
							</c:if>
						</li>
						<li class="section-stats ">
							(${message.messageDate})
							[<a href="ComposeMessage.jsp?composeType=Reply&messageId=${topic.messageId}&replyId=1">引用文章</a>]
						</li>
					</ul>
				</div>
				<div>
					${message.messageBody}
				</div>
			</div>
		</li>
	</c:forEach>
</ol>
</div>


<jsp:include page="include_footer.jsp" flush="false" />
